<template>
	<view>
		<view style="margin: 20rpx auto;background-color: #FFFFFF;box-sizing: border-box;padding:20rpx 30rpx;border-radius: 16rpx;width: 92%;">
			<view style="overflow: hidden;">
				<view style="float: left;width: 23%;overflow: hidden;">
					<image :src="xq.member.group.avatar" style="width: 112rpx;height: 112rpx;border-radius: 50%;display: block;" mode=""></image>
				</view>
				<view style="width: 77%;float: left;padding: 10rpx 0;">
					<view style="color: #000000;font-size: 30rpx;font-weight: 600;line-height: 50rpx;" class="yihang">
						{{xq.member.group.name || ''}}
					</view>
					<view style="color: #999999;font-size: 24rpx;line-height: 50rpx;" class="yihang">
						{{xq.member.group.introduction || ''}}
					</view>
				</view>
			</view>
		</view>
		<view style="width:88%;margin: 20rpx auto;line-height: 60rpx;color: #333333;font-size: 32rpx;font-weight: 600;">
			申请理由
		</view>
		<textarea :disabled="true" v-model="remark" placeholder-style="color:#999;" placeholder="请输入申请理由" style="width: 92%;box-sizing: border-box;padding: 30rpx;line-height: 40rpx;font-size: 28rpx;color: #666;background-color: #fff;border-radius: 15rpx;margin: 0 auto;" />
		<view v-if="xq.is_check==2">
			<view v-if="index==1">
				<view style="width: 690rpx;height: 90rpx;font-weight: 600;margin:200rpx auto 0;display: flex;">
					<view @click="qun_jujue" style="background: #FFFFFF;border-radius: 46rpx;line-height: 90rpx;text-align: center;color:#E60012;font-size: 28rpx;flex: 1;">
						拒绝
					</view>
					<view @click="qun_tongyi" style="background: #1FB0AC;border-radius: 46rpx;line-height: 90rpx;text-align: center;color:#ffffff;font-size: 28rpx;flex: 1;margin-left: 40rpx;">
						确定
					</view>
				</view>
			</view>
			<view v-if="index==2">
				<view style="width: 690rpx;height: 90rpx;font-weight: 600;margin:200rpx auto 0;display: flex;">
					<view @click="yonghu_jujue" style="background: #FFFFFF;border-radius: 46rpx;line-height: 90rpx;text-align: center;color:#E60012;font-size: 28rpx;flex: 1;">
						拒绝
					</view>
					<view @click="yonghu_tongyi" style="background: #1FB0AC;border-radius: 46rpx;line-height: 90rpx;text-align: center;color:#ffffff;font-size: 28rpx;flex: 1;margin-left: 40rpx;">
						确定
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import isAuditIos from '@/common/isAuditIos.js'
	export default{
		mixins: [isAuditIos],
		data(){
			return{
				index:'',
				id:'',
				xq:{},
				remark:''
			}
		},
		onLoad(option) {
			this.index=option.index
			this.id=option.notice_id
			this.xiang()
		},
		methods:{
			xiang:function(){
					this.post('api/chat/notice_info',{notice_id:this.id},true).then(res=>{
						console.log(res)
						if(res.code==1){
							this.xq=res.data
							this.remark=res.data.member.remark
						}
					})
				// }
			},
			qun_jujue:function(){
				this.post('api/chat/refuse_join',{notice_id:this.id},true).then(res=>{
					if(res.code==1){
						uni.showToast({
							title: res.msg,
							icon: "none",
							duration: 1000
						})
						setTimeout(function(){
							uni.navigateBack({
								delta:1
							})
						},1500)
					}else{
						uni.showToast({
							title: res.msg,
							icon: "none",
							duration: 1000
						})
					}
				})
			},
			qun_tongyi:function(){
				let that=this
				this.post('api/client/info', '', true).then(res => {
					console.log(res)
					if (res.code == 1) {
						if(res.data.is_vip==1){
							that.post('api/chat/consent_join',{notice_id:that.id},true).then(res=>{
								if(res.code==1){
									uni.showToast({
										title: res.msg,
										icon: "none",
										duration: 1000
									})
									setTimeout(function(){
										uni.navigateBack({
											delta:1
										})
									},1500)
								}else{
									uni.showToast({
										title: res.msg,
										icon: "none",
										duration: 1000
									})
								}
							})
						}else if(res.data.is_vip==2){
							if (that.iosUpAppStore) {
								uni.showModal({
									title: '提示',
									content: '您的会员已到期,只有会员才可以操作,请前去续费会员！',
									success: function (res1) {
										if (res1.confirm) {
											uni.navigateTo({
												url:'../../subpages/pages/vip'
											})
										} else if (res1.cancel) {

										}
									}
								});
							} else {
								that.post('api/chat/consent_join',{notice_id:that.id},true).then(res=>{
									if(res.code==1){
										uni.showToast({
											title: res.msg,
											icon: "none",
											duration: 1000
										})
										setTimeout(function(){
											uni.navigateBack({
												delta:1
											})
										},1500)
									}else{
										uni.showToast({
											title: res.msg,
											icon: "none",
											duration: 1000
										})
									}
								})
							}

						}else if(res.data.is_vip==0){
							if (that.iosUpAppStore) {
								uni.showModal({
									title: '提示',
									content: '您的会员已到期,只有会员才可以操作,请前去续费会员！',
									success: function (res1) {
										if (res1.confirm) {
											uni.navigateTo({
												url:'../../subpages/pages/vip'
											})
										} else if (res1.cancel) {

										}
									}
								});
							} else {
								that.post('api/chat/consent_join',{notice_id:that.id},true).then(res=>{
									if(res.code==1){
										uni.showToast({
											title: res.msg,
											icon: "none",
											duration: 1000
										})
										setTimeout(function(){
											uni.navigateBack({
												delta:1
											})
										},1500)
									}else{
										uni.showToast({
											title: res.msg,
											icon: "none",
											duration: 1000
										})
									}
								})
							}
						}
					}
				})

			},



			yonghu_jujue:function(){
				this.post('api/chat/user_refuse_join',{notice_id:this.id},true).then(res=>{
					if(res.code==1){
						uni.showToast({
							title: res.msg,
							icon: "none",
							duration: 1000
						})
						setTimeout(function(){
							uni.navigateBack({
								delta:1
							})
						},1500)
					}else{
						uni.showToast({
							title: res.msg,
							icon: "none",
							duration: 1000
						})
					}
				})
			},
			yonghu_tongyi:function(){
				let that=this
				this.post('api/client/info', '', true).then(res => {
					console.log(res)
					if (res.code == 1) {
						if(res.data.is_vip==1){
							that.post('api/chat/user_consent_join',{notice_id:that.id},true).then(res=>{
								if(res.code==1){
									uni.showToast({
										title: res.msg,
										icon: "none",
										duration: 1000
									})
									setTimeout(function(){
										uni.navigateBack({
											delta:1
										})
									},1500)
								}else{
									uni.showToast({
										title: res.msg,
										icon: "none",
										duration: 1000
									})
								}
							})
						}else if(res.data.is_vip==2){
							if (that.iosUpAppStore) {
								uni.showModal({
									title: '提示',
									content: '您的会员已到期,只有会员才可以操作,请前去续费会员！',
									success: function (res1) {
										if (res1.confirm) {
											uni.navigateTo({
												url:'../../subpages/pages/vip'
											})
										} else if (res1.cancel) {

										}
									}
								});
							} else {
								that.post('api/chat/user_consent_join',{notice_id:that.id},true).then(res=>{
									if(res.code==1){
										uni.showToast({
											title: res.msg,
											icon: "none",
											duration: 1000
										})
										setTimeout(function(){
											uni.navigateBack({
												delta:1
											})
										},1500)
									}else{
										uni.showToast({
											title: res.msg,
											icon: "none",
											duration: 1000
										})
									}
								})
							}

						}else if(res.data.is_vip==0){
							if (that.iosUpAppStore) {
								uni.showModal({
									title: '提示',
									content: '您的会员已到期,只有会员才可以操作,请前去续费会员！',
									success: function (res1) {
										if (res1.confirm) {
											uni.navigateTo({
												url:'../../subpages/pages/vip'
											})
										} else if (res1.cancel) {

										}
									}
								});
							} else {
								that.post('api/chat/user_consent_join',{notice_id:that.id},true).then(res=>{
									if(res.code==1){
										uni.showToast({
											title: res.msg,
											icon: "none",
											duration: 1000
										})
										setTimeout(function(){
											uni.navigateBack({
												delta:1
											})
										},1500)
									}else{
										uni.showToast({
											title: res.msg,
											icon: "none",
											duration: 1000
										})
									}
								})
							}
						}
					}
				})

			},
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #F5F5F5;
		padding-bottom: 40rpx;
		font-family: Demibold;
	}
</style>